package thread;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class Demo27 {
    public static void main(String[] args) throws InterruptedException {
        BlockingQueue<String> queue=new LinkedBlockingQueue<>(100);
        for (int i = 0; i < 100; i++) {
            queue.put("aaa");
        }
        System.out.println("队列已满");
        queue.put("aaa");//阻塞等待
        System.out.println("尝试put元素");
    }
    public static void main1(String[] args) throws InterruptedException {
        BlockingQueue<String> queue=new LinkedBlockingQueue<>();
        //queue.put("aaa");
        String elem=queue.take();//阻塞等待 offer和poll也可以用但区别是没有阻塞功能
        System.out.println(elem);
    }
}
